package video.web;

import net.sf.json.JSONObject;
import util.GetHtml;
/**
 * url example http://www.56.com/u62/v_NjQ5MDgyMDQ.html
 * @author ladjzero
 *
 */
public class _56 extends SuperParser{
	
	private boolean hasJson = false;
	
	private String jUrl;
	private JSONObject jInfo;
	private String videoUrl;
	
	public _56(String videoUrl){
		super(videoUrl);	
	}
	
	public boolean isReachable(){
		if( null == content )
			return false;
		return true;
	}
	
	public String getFileUrl(){
		if( !hasJson )
			getJson();
		return JSONObject.fromObject( jInfo.getJSONArray("rfiles").get(0) ).getString("url");
	}
	
	public String getImage(){
		if( !hasJson )
			getJson();
		return jInfo.getString("bimg");
	}
	
	public String getSwf(){
		return "http://player.56.com/"+videoUrl.substring(videoUrl.indexOf("v_"), videoUrl.indexOf(".html"))+".swf";
	}
	
	private void getJson(){
		jUrl = "http://vxml.56.com/json/"+vid+"/";
		String receive = new GetHtml().get( jUrl ,"utf-8");
		jInfo = JSONObject.fromObject( receive ).getJSONObject("info");
	}
}
